package com.dm.server.controller;
import com.dm.server.MQ.SpringProducer;
import com.dm.server.limiter.SlideWindowsLimiter;
import com.dm.server.service.VoucherOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dm.server.dto.Result;
import javax.annotation.Resource;
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 虎哥
 * @since 2021-12-22
 */
@RestController
@RequestMapping("/voucher-order")
public class VoucherOrderController {
    @Resource
    private VoucherOrderService voucherOrderService;

    @Resource
    private SlideWindowsLimiter slideWindowsLimiter;

    //这里可以采用限流
    @PostMapping("seckill/{id}")
    public Result seckillVoucher(@PathVariable("id") Long voucherId) {

        //slideWindowsLimiter.canAccess(10,5);
        return voucherOrderService.seckillVouche(voucherId);

    }
}
